"""djangoProject URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.conf.urls import url
from django.contrib import admin
from django.urls import path, include
from django.views.decorators.csrf import csrf_exempt
from django.views.generic import TemplateView
from django.views.static import serve

from apps.operation.views import IndexView
from apps.organization.views import OrgView
from apps.users.views import LoginView, LogoutView, SendSmsView, DynamicLoginView, RegisterView
import xadmin
from djangoProject.settings import MEDIA_ROOT

urlpatterns = [
    path('admin/', admin.site.urls),
    path('xadmin/', xadmin.site.urls),
    # path("", TemplateView.as_view(template_name="index.html"), name="index"),
    path("", IndexView.as_view(), name='index'),
    path("login/", LoginView.as_view(), name="login"),
    path("register/", RegisterView.as_view(), name="register"),
    path("d_login/", DynamicLoginView.as_view(), name="d_login"),
    path("logout/", LogoutView.as_view(), name="logout"),
    path('captcha/', include('captcha.urls')),
    url(r"send_sms/", csrf_exempt(SendSmsView.as_view()), name="sendsms"),

    # 课程机构相关
    url(r'^org/', include(('apps.organization.urls', "organizations"), namespace="org")),
    # 用户操作相关
    url(r'^op/', include(('apps.operation.urls', "operation"), namespace="op")),
    # 课程相关
    url(r'^course/', include(('apps.courses.urls', "courses"), namespace="course")),
    # 用户中心
    url(r'^users/', include(('apps.users.urls', "users"), namespace="users")),
    # 课程作业相关



    # 配置上传文件的访问url
    url(r'^media/(?P<path>.*)$', serve, {"document_root": MEDIA_ROOT}),
    # url(r'^static/(?P<path>.*)$', serve, {"document_root":STATIC_ROOT}),
    #     富文本编辑器相关
    url(r'^ueditor/', include('DjangoUeditor.urls')),
]
